package com.wb3.organizer.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.wb3.organizer.model.Account;
import com.wb3.organizer.service.AccountService;

public class LoginAction extends ActionSupport implements SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String msg;

	private Account account;

	private Map<String, Object> session;

	private AccountService service;

	public void setSession(Map<String, Object> inSession) {
		this.session = inSession;
	}

	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public AccountService getService() {
		return service;
	}

	public void setService(AccountService service) {
		this.service = service;
	}

	@Override
	public String execute() throws Exception {
		if(service.accountCheck(account)){
			session.put("account", account.clone());
			return SUCCESS;
		}
		msg = "您输入的用户名和密码有误!!";
		return ERROR;
	}

}
